export default [{
        path: "/",
        redirect: "/home"
    },
    {
        path: "/login",
        name: "login",
        component: () => import("@pages/Login")
    },
    {
        path: "/register",
        name: "register",
        component: () => import("@pages/Register")
    },
    {
        path: "/home",
        name: "home",
        component: () => import("@pages/Home")
    },
    {
        path: "/search/:keyword?",
        name: "search",
        component: () => import("@pages/Search")
    },
    {
        path: "/detail",
        name: "detail",
        component: () => import("@pages/Detail")
    },
    {
        path: "/addCartSuccess",
        name: "addCartSuccess",
        component: () => import("@pages/AddCartSuccess"),
        beforeEnter: (to, from, next) => {
            if(from.name==="detail"){
                next()
            }else{
                next("/detail")
            }
        }
    },
    {
        path: "/shopCart",
        name: "shopCart",
        component: () => import("@pages/ShopCart")
    },
    {
        path: "/center",
        // name: "center",
        redirect:"/center/myOrder",
        component: () => import("@pages/Center"),
        children: [{
                path: "/center/myOrder",
                name: "myOrder",
                component: () => import("@pages/Center/components/MyOrder")
            },
            {
                path: "/center/teamOrder",
                name: "teamOrder",
                component: () => import("@pages/Center/components/TeamOrder")
            }
        ]
    },
    {
        path: "/pay/:orderId",
        name: "pay",
        component: () => import("@pages/Pay"),
        // 路由独享守卫， 判断是不是***过来的
        beforeEnter: (to, from, next) => {
            if(from.name==="trade" ){
                next()
            }else{
                next("/shopCart")
            }
        }
        
    },
    {
        path: "/paySuccess",
        name: "paySuccess",
        component: () => import("@pages/PaySuccess"),
        // 路由独享守卫， 判断是不是***过来的
        beforeEnter: (to, from, next) => {
            if(from.name==="pay" ){
                next()
            }else{
                next("/shopCart")
            }
        }        
    },
    {
        path: "/trade",
        name: "trade",
        component: () => import("@pages/Trade"),
        // 路由独享守卫， 判断是不是***过来的
        beforeEnter: (to, from, next) => {
            if(from.name==="shopCart" ){
                next()
            }else{
                next("/shopCart")
            }
        }
    }
]